//by 略游
if (isNull player) exitwith {} ;

fn_handHitSwitch = 
{
	if(player getvariable["hand_hit_switch",true]) then
	{
		player setvariable["hand_hit_switch",false];
		hint "关闭了近战攻击";
	}
	else
	{
		player setvariable["hand_hit_switch",true];
		hint "开启了近战攻击";
	};
	
};

fn_handHit = 
{	
	if(!(player getvariable["hand_hit_switch",true])) exitwith{};
	
	private _ani_name = animationState player;
	if (player == vehicle player &&
		currentWeapon player == "" &&	
		count _ani_name <= 36 &&
		(_ani_name find "amovpercm") == 0 && 
		!(player getvariable["hand_hit",false])) then
	{
		[] spawn
		{
			player setvariable["hand_hit",true];
			[player, "AwopPercMstpSgthWnonDnon_end"] remoteExec ["switchMove", 0];
			[player, format["wave_0%1", (floor random 2) + 1]] remoteExec ["say3D", 0];
			sleep 0.5;
			//造成伤害
			private _list = player nearEntities [["Man"], 1.8];
			if(count _list <= 1) exitwith
			{
				//载具穿透
				private _list_car = player nearEntities[["StaticWeapon", "Car"], 2.2];
				if(count _list_car > 0) then
				{
					{
					//判断乘员数
						if((count crew _x) <= 2) then
						{
							{
								if(_x != player
								&& {alive _x}
								&& {side group _x != civilian} ) exitwith
								{	
									[_x, "dead_01"] remoteExec ["say3D", 0];
									sleep 0.5;					
									if(isPlayer _x) then
									{
										//_x setDamage 0.9;
										[_x, player, objNull, [0,0]]spawn FAR_unit_Unconscious;
									}
									else
									{
										_x setDamage 1.0;
									};		
								};
							}forEach crew _x;
						};
					}forEach _list_car;
				};
				player setvariable ["hand_hit",false];
			};
			
			{
				if(_x != player
				&& {alive _x}
				&& {side group _x != civilian} ) exitwith
				{	
					[_x, "dead_01"] remoteExec ["say3D", 0];
					sleep 0.5;					
					if(isPlayer _x) then
					{
						//_x setDamage 0.9;
						[_x, player, objNull, [0,0]]spawn FAR_unit_Unconscious;
					}
					else
					{
						_x setDamage 1.0;
					};		
				};
			}forEach _list;
			

			sleep 1.5;
			player setvariable ["hand_hit",false];
		};
		
	};
	
};
fn_handHit2 = 
{	
	if(!(player getvariable["hand_hit_switch",true])) exitwith{};
	if(!isNil "as_cb_ing" && as_cb_ing) exitwith{};
	[player, "AmovPercMstpSnonWnonDnon_exerciseKata"] remoteExec ["playMoveNow", 0];
};
fn_handHit3 = 
{	
	if(!(player getvariable["hand_hit_switch",true])) exitwith{};
	if(!isNil "as_cb_ing" && as_cb_ing) exitwith{};
	[player, "AmovPercMstpSnonWnonDnon_exercisekneeBendB"] remoteExec ["playMoveNow", 0];
};
fn_handHit4 = 
{	
	if(!(player getvariable["hand_hit_switch",true])) exitwith{};
	if(!isNil "as_cb_ing" && as_cb_ing) exitwith{};
	[player, "AmovPercMstpSnonWnonDnon_exercisePushup"] remoteExec ["playMoveNow", 0];
};


waitUntil{!(isNull(findDisplay 46))};
(findDisplay 46)displayAddEventHandler["KeyUp","if(_this select 1==0x37)then{call fn_handHitSwitch};if(_this select 1==0xC8)then{call fn_handHit};if(_this select 1==0xCB)then{call fn_handHit2};if(_this select 1==0xD0)then{call fn_handHit3};if(_this select 1==0xCD)then{call fn_handHit4}"];

